Page({

  /**
   * 页面的初始数据
   */
  data: {
    imgArr: [
      'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1534241231427&di=3fd6a9caf18f4000babb07eb8e68a286&imgtype=0&src=http%3A%2F%2Fwww.maogp.com%2FUpFile%2F20140421170455.jpg',

      "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1534241502235&di=9cb6688bb3ee1b055d8ef5ba68579e8e&imgtype=0&src=http%3A%2F%2Fi3.sinaimg.cn%2Fgm%2F2014%2F0902%2FU7232P115DT20140902095707.jpg",

      "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1534241502235&di=aa6c2499e518494070403c90d0bbb798&imgtype=0&src=http%3A%2F%2Fwx4.sinaimg.cn%2Fnmw690%2Fad5c3905ly1fcy3wlk4tij20j60xzjwe.jpg",
      
      "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1534241502229&di=027a0c51e40caaa651c87f70fcb001da&imgtype=0&src=http%3A%2F%2Fimge.gmw.cn%2Fsite2%2F20161227%2Ff44d305ea48819cc1db558.jpeg"

    ]
  },
  previewImg: function (e) {
    console.log(e.currentTarget.dataset.index);
    var index = e.currentTarget.dataset.index;
    var imgArr = this.data.imgArr;
    wx.previewImage({
      current: imgArr[index],     //当前图片地址
      urls: imgArr,               //所有要预览的图片的地址集合 数组形式
      success: function (res) { },
      fail: function (res) { },
      complete: function (res) { },
    })
  },
  index: function () {
    wx.reLaunch({
      url: '../index/index',
    })
  },
  mytracks: function () {
    wx.navigateTo({
      url: '../mytracks/mytracks',
    })
  },
  share: function () {
    console.log("这里是分享的事件");
    // var openid = getApp().globalData.openid;
    // var nickname = getApp().globalData.nickName;
    // var that = this;
    // wx.request({
    //   url: getApp().globalData.API_URI + '/index.php/face_share',
    //   data: { //appid 与 secret为对应小程序项目后台获取
    //     'openid': openid,
    //     'nickname': nickname,
    //   },
    //   header: {//请求头  
    //     "Content-Type": "application/x-www-form-urlencoded"
    //   },
    //   method: 'POST',
    //   success: function (res) {
    //     console.log(res.data)
    //     that.setData({ jifen: res.data.jifen, })
    //   }
    // })
  },


  onShareAppMessage: function () {
    return {
      title: '快看，这是我的变脸图集，你也来试试？',
      path: 'pages/pholist/pholist?static_id=' + getApp().globalData.static_id,
      //imageUrl: "http://citiao.cndzys.com/images/hongbao.jpg",
      success: function (res) {
        // 转发成功
        console.log("转发成功");
      },
      fail: function (res) {
        // 转发失败
        console.log("转发失败");
      }
    }
  },



  onLoad: function (options) {
    var date = new Date();
    var myDate = date.getFullYear() + '-' + (date.getMonth() + 1) + '-' + date.getDate()
    this.setData({myDate: myDate })
    console.log(myDate);
    getApp().globalData.static_id = options.static_id;
    var that= this;
    //获取静态资料
    wx.request({
      url: getApp().globalData.API_URI + '/index.php/face_static_albums',
      data: { 
        'static_id': getApp().globalData.static_id,
      },
      header: { "Content-Type": "application/x-www-form-urlencoded" },
      method: 'POST',
      success: function (res) {
        console.log("这是上传完图片回调回来的=====================");
        console.log(res.data);
        that.setData({
          title: res.data.title,
          imgArr: res.data.imgarr,
          nickname: res.data.nickname,
          avatar_url: res.data.avatarurl,
          rdnum: res.data.rdnum,
          myDate: res.data.riqi,
        })
        
      }
    })
    
    
    // this.setData({
    //   title: options.title,
    //   static_id: options.static_id,
    //   myDate: myDate,
    //   imgArr: getApp().globalData.imgArr,
    //   nickname: getApp().globalData.nickName,
    //   avatar_url: getApp().globalData.avatarUrl,
    //   })
    // var title = options.title;
    // var imgArr = options.imgArr;
    // console.log("传过来的图片是============");
    // console.log(options.static_id);
    // console.log("传过来的标题是============");
    // console.log(title);
  },

  
})